package com.gph.saviorframework.shiro;

import com.gph.saviorframework.util.SecUtils;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

public class MD5PasswordMatcher extends SimpleCredentialsMatcher {

    public MD5PasswordMatcher(){

    }

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {

        Object tokenCredentials = SecUtils.getMD5(toBytes(token.getCredentials()));
        Object accountCredentials = info.getCredentials();

        return equals(tokenCredentials,accountCredentials);
    }
}
